package homework.day304;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.util.List;
import java.util.Vector;

public class Prob2 {

	public static void main(String[] args) throws IOException {
		Prob2 p2 = new Prob2();
		List scores = p2.getScore("C:\\data.txt");
		for(int i=0; i<scores.size(); i++) {
			Score score = (Score)scores.get(i);
			System.out.println(score.getName() + " : "
									+ score.getKor() + " " + score.getEng()
									+ " " + score.getMath() + " " 
									+ score.getSum());
		}
//		for(List scoes : scores) {
//			
//		}
	}
	
	public List<Score> getScore(String fileName) throws IOException {
		
		BufferedReader br = new BufferedReader(new FileReader(fileName));
		List<Score> inforList = new Vector<Score>(); 
		//String[] inforArr = null;
		String source;
		
		while(true) {
			source = br.readLine();
			if(source == null) {
				break;
			}
			String[] inforArr = source.split("/");
			String name = inforArr[0];
			int kor = Integer.parseInt(inforArr[1]);
			int eng = Integer.parseInt(inforArr[2]);
			int math = Integer.parseInt(inforArr[3]);
			int sum = kor + eng + math;
			inforList.add(new Score(name, kor, eng, math, sum));	
		}	
		br.close();
		return inforList;	
	}
}

class Score {
	
	private String name;
	private int kor;
	private int eng;
	private int math;
	private int sum;
	
	public Score() {
	}
	
	public Score(String name, int kor, int eng, int math, int sum) {
		this.name = name;
		this.kor = kor;
		this.eng = eng;
		this.math = math;
		this.sum = sum;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public int getKor() {
		return kor;
	}
	
	public void setKor(int kor) {
		this.kor = kor;
	}
	
	public int getEng() {
		return eng;
	}
	
	public void setEng(int eng) {
		this.eng = eng;
	}
	
	public int getMath() {
		return math;
	}
	
	public void setMath() {
		this.math = math;
	}

	public int getSum() {
		return sum;
	}

	public void setSum(int sum) {
		this.sum = sum;
	}	
}
